<? isset($format) || $format =  url_param(null, array('page' => '%d')); ?>
<? if (isset($page) && $page->total_pages > 1): ?>
<ul class="pagination <?=get_var('extraClass')?>">

    <li class="<?=on($page->current <= 1, 'disabled')?>">
        <a href="<?=furl($format, $page->before)?>" title="<?=__('Previous')?>">
            <i class="fa fa-angle-left"></i>
            <?=__('Previous')?>
        </a>
    </li>

    <? if ($page->total_pages < 10): /* ? Previous 1 2 3 4 5 6 7 8 9  Next ? */ ?>

        <? for ($i = 1; $i <= $page->total_pages; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? elseif ($page->current < 6): /* ? Previous  1 2 3 4 5 6 7 … 26  Next ? */ ?>

        <? for ($i = 1; $i <= 7; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

        <li><span>&hellip;</span></li>
        <li><a href="<?=furl($format, $page->total_pages)?>"><?=$page->total_pages?></a></li>

    <? elseif ($page->current > $page->total_pages - 5): /* ? Previous  1 … 20 21 22 23 24 25 26  Next ? */ ?>

        <li><a href="<?=furl($format, 1)?>">1</a></li>
        <li><span>&hellip;</span></li>

        <? for ($i = $page->total_pages - 6; $i <= $page->total_pages; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? else: /* ? Previous  1 … 6 7 8 9 10 11 12 13 … 26  Next ? */ ?>

        <li><a href="<?=furl($format, 1)?>">1</a></li>
        <li><span>&hellip;</span></li>

        <? for ($i = $page->current - 3; $i <= $page->current + 3; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

        <li><span>&hellip;</span></li>
        <li><a href="<?=furl($format, $page->total_pages)?>"><?=$page->total_pages?></a></li>

    <? endif ?>

    <li class="<?=on($page->current >= $page->total_pages, 'disabled')?>">
        <a href="<?=furl($format, $page->next)?>" title="<?=__('Next')?>">
            <?=__('Next')?>
            <i class="fa fa-angle-right"></i>
        </a>
    </li>

    <li>
        <span><?=__('Total :total records', array(':total' => $page->total_items))?></span>
    </li>
</ul>
<? endif ?>
